package com.alogic.lucene.indexer;

import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import com.alogic.lucene.core.Indexer;

import java.util.HashMap;
import java.util.Map;

/**
 * 基于RAMDirectory的Indexer
 * 
 * @author duanyy
 *
 */
public class RAM extends Indexer.Abstract{
	/**
	 * dircectory
	 */
	protected Directory index = new RAMDirectory();

	protected Map<String,Long> lastBuildTimes = new HashMap<String,Long>();

	@Override
	public Directory getDirectory() {
		return index;
	}

	@Override
	public long getLastBuildTime(String counter) {
		Long found = lastBuildTimes.get(counter);
		return found == null ? 0:found;
	}

	@Override
	public void commitLastBuildTime(String counter, long tt) {
		lastBuildTimes.put(counter,tt);
	}

}
